// 防抖
function debounce(fn,delay){
    let timer = null //借助闭包
    return function() {
		clearTimeout(timer)
		timer = setTimeout(() => {
			fn.apply(this, arguments);
		}, 1000)
    }
}
// 节流
function throttle(fn, delay) {
	let valid = true;
	return function() {
		if (valid) {
			setTimeout(() => {
				fn.apply(this, arguments);
				valid = true;
			}, delay)
			valid = false;
		}
	}
}

export {
	debounce,
	throttle
}
